#ifndef __ML_I2C_H
#define __ML_I2C_H
#include "headfile.h"
#include "stdio.h"
#include <stdint.h>
#include <stdbool.h>


#define I2C_WR	0		
#define I2C_RD	1		

///* Port definition for Pin Group NCHD12_PORT */
//#define NCHD12_PORT_PORT                                                 (GPIOA)

///* Defines for SCL: GPIOA.0 with pinCMx 1 on package pin 33 */
//#define NCHD12_PORT_SCL_PIN                                      (DL_GPIO_PIN_25)
//#define NCHD12_PORT_SCL_IOMUX                                     (IOMUX_PINCM1)
///* Defines for SDA: GPIOA.1 with pinCMx 2 on package pin 34 */
//#define NCHD12_PORT_SDA_PIN                                      (DL_GPIO_PIN_26)
//#define NCHD12_PORT_SDA_IOMUX                                     (IOMUX_PINCM2)


void _bsp_analog_i2c_start(void);
void _bsp_analog_i2c_stop(void);
void _bsp_analog_i2c_nack(void);
void _bsp_analog_i2c_ack(void);
uint8_t _bsp_analog_i2c_wait_ack(void);
uint8_t _bsp_analog_i2c_read_byte(void);
void _bsp_analog_i2c_send_byte(uint8_t data);
void _bsp_analog_i2c_send_byte_nask(uint8_t data);

uint8_t i2c_CheckDevice(uint8_t _Address);

//移植江写科技的i2c
#define GPIO_scl_PORT GPIOA
#define GPIO_scl_PIN_1_PIN  DL_GPIO_PIN_25
#define GPIO_sda_PORT GPIOA
#define GPIO_sda_PIN_0_PIN  DL_GPIO_PIN_26
#define GPIO_sda_PIN_0_IOMUX IOMUX_PINCM55
#define GPIO_scl_PIN_1_IOMUX IOMUX_PINCM59

void MyI2C_Init(void);
void MyI2C_Start(void);
void MyI2C_Stop(void);
void MyI2C_SendByte(uint8_t Byte);
uint8_t MyI2C_R_SDA(void);
uint8_t MyI2C_ReceiveByte(void);
void MyI2C_SendAck(uint8_t AckBit);
uint8_t MyI2C_ReceiveAck(void);
void MyI2C_W_SCL(uint8_t BitValue);
void MyI2C_W_SDA(uint8_t BitValue);
//
#define GRAY_ADDRESS 0x40 // I2C从机地址
uint8_t GRAY_ReadReg(uint8_t RegAddress) ;
void GRAY_WriteReg(uint8_t RegAddress, uint8_t Data);
#endif


